package com.violet.auth.client.store;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
 * 类说明: 认证服务器使用数据库存取令牌
 *
 * @author wqf
 * @date 2024/9/14 16:00
 */
@Configuration
@ConditionalOnProperty(prefix = "vio.oauth2.token.store", name = "type", havingValue = "db")
public class AuthDbTokenStore {

    @Resource
    private DataSource dataSource;

    @Bean
    public TokenStore tokenStore(){
        return new JdbcTokenStore(dataSource);
    }
}
